---@class webbert_rt_panel_singlebtn
---@field name string # 按钮名字
---@field on_click_fn_client fun()|nil # 按钮点击时调用
---@field hint string|nil # 技能详细描述


---@class webbert_rt_panel
---@field when_any_btn_click_fn_client fun(which_btn:integer) # 所有按钮点击时最后调用
---@field btns webbert_rt_panel_singlebtn[]

local lang = STRINGS.MOD_WEBBER_THE_TRAINER.webbert_rt_panel

---@type table<string,webbert_rt_panel> # 键为 武器.webbert_rt_panel
local main = {
    staff_arachnidnexus_common = {
        when_any_btn_click_fn_client = function(which_btn)
            if ThePlayer then
                local wp = ThePlayer.replica.inventory and ThePlayer.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
                if wp and wp.prefab == 'staff_arachnidnexus' then
                    SendModRPCToServer(GetModRPC('webber_the_trainer','rt_panel_click'),which_btn)
                    if ThePlayer.HUD and ThePlayer.HUD.rt_panel then
                        ThePlayer.HUD.rt_panel:Hide()
                    end
                end
            end
        end,
        btns = {
            {
                name = lang[1][1],
                hint = lang[1][2],
            },
            {
                name = lang[2][1],
                hint = lang[2][2],
            },
            {
                name = lang[3][1],
                hint = lang[3][2],
            },
            {
                name = lang[4][1],
                hint = lang[4][2],
            },
            {
                name = lang[5][1],
                hint = lang[5][2],
            },
            {
                name = lang[6][1],
                hint = lang[6][2],
            },
            {
                name = lang[7][1],
                hint = lang[7][2],
                on_click_fn_client = function ()
                    if ThePlayer and ThePlayer.HUD and ThePlayer.HUD.webbert_panel and ThePlayer.HUD.webbert_panel.panel then
                        if ThePlayer.HUD.webbert_panel.panel.shown then
                            ThePlayer.HUD.webbert_panel.panel:Hide()
                        else
                            ThePlayer.HUD.webbert_panel.panel:Show()
                        end
                    end
                end
            },
            {
                name = lang[8][1],
                hint = lang[8][2],
                on_click_fn_client = function ()
                    if ThePlayer and ThePlayer.HUD and ThePlayer.HUD.controls then
                        ThePlayer.HUD.controls:ToggleMap()
                    end
                end
            },
        },
    }
}


for name,tbl in pairs(main) do
    for _,v in ipairs(tbl.btns) do
        local old_hint = v.hint
        if old_hint then
            v.hint = SUGAR_webber_the_trainer:limitMultiLineStringSingleLineMaxLen(old_hint,15)
        end
    end
end

return main